/*
 * @Author: szx
 * @Date: 2022-03-05 14:51:16
 * @LastEditTime: 2022-03-05 15:05:31
 * @Description:
 * @FilePath: \leetcode\1-99\98\98_2.js
 */
var isValidBST = function (root) {
    // 需要继续上一个值
    let maxVal = -Infinity;
    const dfs = (root) => {
        // 中序遍历
        if (!root) return true;
        const left = dfs(root.left);
        if (root.val > maxVal) maxVal = root.val;
        else return false;
        const right = dfs(root.right);
        return left && right;
    };
    return dfs(root);
};
